﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace EntityTools.Logic.Interface
{
    interface IDatabaseInfo
    {
        /// <summary>
        /// 获取数据库表
        /// </summary>
        /// <param name="dbName">数据库名称</param>
        /// <returns>表名数组</returns>
        List<string> GetTablesFromDb(string dbName);

        /// <summary>
        /// 获取字段信息
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <returns>字段信息数组</returns>
        List<DbFieldInfo> GetFieldsFromTable(string tableName);
    }

    /// <summary>
    /// 字段信息描述
    /// </summary>
    struct DbFieldInfo
    {
        public string   Name;           //字段名称
        public string   FieldType;      //字段C#类型
        public string   Sequence;       //字段顺序
        public string   IsPrimeKey;     //是否主键
        public string   IsUnique;       //是否唯一
        public string   IsNotNull;      //是否可空
        public string   IsForeignKey;   //是否外键
        public string   DatabaseType;   //数据类型
        public string   Size;           //字段长度
        public string   Description;    //字段描述
        public string   RelTable;       //关联表名称
        public string   RelIdField;     //关联ID字段
        public string   RelNameField;   //关联名称字段
    }
}
